import request from '@/api/request';

// 笔记相关API

// 添加笔记
export function addNote(data: any) {
  return request({
    url: '/api/note',
    method: 'post',
    data
  });
}

// 删除笔记
export function deleteNote(id: number) {
  return request({
    url: `/api/note/${id}`,
    method: 'delete'
  });
}

// 批量删除笔记
export function deleteNotes(ids: number[]) {
  return request({
    url: '/api/note/batch',
    method: 'delete',
    data: ids
  });
}

// 更新笔记
export function updateNote(data: any) {
  return request({
    url: '/api/note',
    method: 'put',
    data
  });
}

// 根据ID获取笔记
export function getNoteById(id: number) {
  return request({
    url: `/api/note/${id}`,
    method: 'get'
  });
}

// 获取所有笔记
export function getAllNotes() {
  return request({
    url: '/api/note',
    method: 'get'
  });
}

// 搜索笔记
export function searchNotes(params: any) {
  return request({
    url: '/api/note/search',
    method: 'get',
    params: {
      title: params.title
    }
  });
}